<?php
/**
 * Created by PhpStorm.
 * User: yy
 * Date: 2019/6/25
 * Time: 16:29
 */

namespace app\api\controller;

use app\common\service\airquality\AirQualityImproveStatisticsService;

/**
 * 空气质量预报-改善统计
 * Class AirQualityImproveStatistics
 * @package app\api\controller
 */
class AirQualityImproveStatistics extends BaseController
{
    /**
     * 空气质量趋势图
     * @author yy by 2019/6/25
     */
    public function getAqiTrend()
    {
        $param = $this->request->param();
        # 模拟数据
//        $param = ['start_time' => '2019-06-17', 'end_time' => '2019-06-23', 'region_id'=>53, 'station_id' => 0, 'pollutant_name'=>'so2'];
        $list = [];
        try {
            $airQualityImproveStatisticsService = new AirQualityImproveStatisticsService();
            $list                               = $airQualityImproveStatisticsService->getAqiTrend($param);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('成功', $list);
    }

    /**
     * 行业减排量占比（目前只提供行业id给前台）
     * @author yy by 2019/6/26
     */
    public function getIndustryReduceRate()
    {
        $param = $this->request->param();
        # 模拟数据
//        $param = ['start_time' => '2019-06-17', 'end_time' => '2019-06-23', 'region_id'=>53, 'station_id' => 0, 'pollutant_name'=>'so2'];
        $list = [];
        try {
            $airQualityImproveStatisticsService = new AirQualityImproveStatisticsService();
            $list                               = $airQualityImproveStatisticsService->getIndustryReduceRate($param);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('成功', $list);
    }
    /**
     * 行业企业排名（运行浓度、效率、排放量、贡献度）
     * @author yy by 2019/6/26
     */
    public function getCompanyRank()
    {
        $param = $this->request->param();
        # 模拟数据
//        $param = ['start_time' => '2019-06-17', 'end_time' => '2019-06-23', 'region_id' => 53, 'station_id' => 0, 'plan_id' => 1, 'is_sulfur' => 1, 'industry_id' => 1];
        $list  = [];
        try {
            $airQualityImproveStatisticsService = new AirQualityImproveStatisticsService();
            $list                               = $airQualityImproveStatisticsService->getCompanyRank($param);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('成功', $list);
    }
}